{% extends 'views/base.html' %}
{% block body %}
<form class="was-validated" action="/create" method="POST">
    <header class="editor-header">
        <input type="text" class="article-header" placeholder="请输入标题..." name="title">
        <button class="btn btn-info publish" type="submit">发布</button>
    </header>

    <div id="editor">
        <textarea name="content" class="input"></textarea>
        <div class="markdown-body show content"></div>
    </div>
</form>
{% block script %}
<script src="https://cdn.bootcss.com/marked/0.3.19/marked.min.js"></script>
<script>
    var input = $('#editor .input')
    $('#editor .show').html(marked(input.val()))
    // 一边敲一边输出
    input.on('input', function() {
        $('#editor .show').html(marked($(this).val(),{sanitize:true}))
    })
</script>
{% endblock %}

{% endblock %}